package io.github.quickmsg.interate.sharedstrategy;

/**
 * @author Zander.Wu
 */
public class SharedStrategyFactory {

    private static RandomStrategy randomStrategy = new RandomStrategy();
    private static RoundRobinStrategy roundRobinStrategy = new RoundRobinStrategy();
    private static ConsistentHashStrategy consistentHashStrategy = new ConsistentHashStrategy();
    private static StickyStrategy stickyStrategy = new StickyStrategy();

    public static SharedStrategy createSharedStrategy(SharedStrategyType type){
        if(SharedStrategyType.random == type){
            return randomStrategy;
        }else if(SharedStrategyType.round_robin == type){
            return roundRobinStrategy;
        }else if(SharedStrategyType.hash == type){
            return consistentHashStrategy;
        }else if(SharedStrategyType.sticky == type){
            return stickyStrategy;
        }else {
            return randomStrategy;
        }
    }
}
